/**
 * 
 */
package rachauto.metier.services.impl;

import java.util.List;

import rachauto.dto.CandidatDto;
import rachauto.dto.GenericMapper;
import rachauto.exceptions.RachAutoException;
import rachauto.metier.services.pub.CandidatServices;
import rachauto.persistence.dao.pub.CandidatDao;
import rachauto.persistence.jpa.model.Candidat;

/**
 * @author said
 *
 */
public class CandidatServicesImpl implements CandidatServices {
	
	private CandidatDao candidatDao;
	
	public void ajouterCandidat(CandidatDto dto) throws RachAutoException{
		
		Candidat candidat = (Candidat) GenericMapper.readAsEntity(dto, Candidat.class);
		candidatDao.ajouterCandidat(candidat);
		
	}

	@SuppressWarnings("unchecked")
	public List<CandidatDto> rechercherListAllCandidats() throws RachAutoException {
		List<Candidat> list =  candidatDao.rechercherListAllCandidats();
		return (List<CandidatDto>)GenericMapper.readAsListDtos(list, CandidatDto.class);
	}

	/**
	 * @return the candidatDao
	 */
	public CandidatDao getCandidatDao() {
		return candidatDao;
	}

	/**
	 * @param candidatDao the candidatDao to set
	 */
	public void setCandidatDao(CandidatDao candidatDao) {
		this.candidatDao = candidatDao;
	}

}
